package aaaPKg;

import java.util.List;

import com.attilax.ast.AstBuilder;
import com.attilax.ast.AstParser;
import com.attilax.ast.Expression;
 
import com.attilax.fsm.JavaTokener;
import com.attilax.fsm.Token;
import com.attilax.io.pathx;
import com.attilax.ioc.IocFacV3_iocx_iocutil;
import com.attilax.json.AtiJson;
import com.attilax.order.RechargeOrderService;

@Deprecated
public class DslParser {

	public static void main(String[] args) {
	  //   String s="new DslParser().m2(123)";
		System.out.println("");
		System.setProperty("cfgfile", "pay.ini");
	     System.out.println("aa");
	 //  String r=  (String) new DslParser().parse(s);
	 //  System.out.println(r);
	 //    RechargeOrderService sr=  
	    	//	 IocFacV3_iocx_iocutil.getBean(RechargeOrderService.class).insert("123466",125,1598);
	    //
		System.out.println( pathx
			.webAppPath());
		//new String[] {"aa","bb" }; 
		String a="  com.attilax.encry.RSACoder.main(['fixseed','c:/0k/pri.txt','c:/0k/pub.txt']) ";
		a="com.attilax.ioc.IocFacV3_iocx_iocutil.getBean(com.attilax.order.RechargeOrderService.class).insert('123466',125,1598)";
		a="com.attilax.ioc.IocFacV3_iocx_iocutil.getBean(com.attilax.order.RechargeOrderService.class).insert('123466':s,'125':i,'1598':i)";
		
		//	args=" aaaPKg.DslParser.m3(123).m4()";
			List<Token> tokens = new JavaTokener(a).getTokensV3();// er(args).getTokens();
			System.out.println(AtiJson.toJson(tokens));
		 	Expression buildAst = new AstBuilder().buildAstV2(tokens);
			 Object rzt = new AstParser().parse(buildAst);
			 System.out.println(rzt);
			
	//   t2(); t3();t4();t5();
	//	DslParser.m3("").m4();
			// test4getbean();

	}
	
	/**
	attilax    2016年10月24日  下午1:11:01
	 */
	private static void test4getbean() {
		 IocFacV3_iocx_iocutil.getBean(com.attilax.order.RechargeOrderService.class).insert("123466",125,1598);
		
	}

	public void m4() {
		Object o="hh";
		System.out.println ((Integer)o);
		System.out.println(" m4_m4");
		
	}

	private static void t2() {
		String args="  new aaaPKg .DslParser().m2(123) ";
		
	//	args=" aaaPKg.DslParser.m3(123).m4()";
		List<Token> tokens = new JavaTokener(args).getTokens();// er(args).getTokens();
		System.out.println(AtiJson.toJson(tokens));
		Expression buildAst = new AstBuilder().buildAst(tokens);
		Object rzt = new AstParser().parse(buildAst);
	//	System.out.println(AtiJson.toJson(tokens));		
		
		System.out.println("test dysn ok"+ rzt);
		
	}
	
	private static void t3() {
		String args=" aaaPKg.  DslParser.m3(123)  ";
		
	//	args=" aaaPKg.DslParser.m3(123).m4()";
		List<Token> tokens = new JavaTokener(args).getTokens();// er(args).getTokens();
		Expression buildAst = new AstBuilder().buildAst(tokens);
		Object rzt = new AstParser().parse(buildAst);
	//	System.out.println(AtiJson.toJson(tokens));		
		System.out.println("test static ok"+ rzt);
		
	}
	
	private static void t4() {
		String args=" new aaaPKg.DslParser().m3(11).m4().";
		
	//	args=" aaaPKg.DslParser.m3(123).m4()";
		List<Token> tokens = new JavaTokener(args).getTokens();// er(args).getTokens();
		Expression buildAst = new AstBuilder().buildAst(tokens);
		Object rzt = new AstParser().parse(buildAst);
	//	System.out.println(AtiJson.toJson(tokens));		
		System.out.println("test dysn meth chain ok"+ rzt);
		
	}
	
	private static void t5() {
		String args="  aaaPKg.DslParser.m3(11).m4().";
		
	//	args=" aaaPKg.DslParser.m3(123).m4()";
		List<Token> tokens = new JavaTokener(args).getTokens();// er(args).getTokens();
		Expression buildAst = new AstBuilder().buildAst(tokens);
		Object rzt = new AstParser().parse(buildAst);
	//	System.out.println(AtiJson.toJson(tokens));		
		System.out.println("test static meth chain ok"+ rzt);
		
	}

	public  Object parse(String args) {
		// TODO Auto-generated method stub
		System.out.println("..start");
		@SuppressWarnings("unchecked")
		List<Token> tokens = new JavaTokener(args).getTokens();
		Expression buildAst = new AstBuilder().buildAst(tokens);
		Object rzt = new AstParser().parse(buildAst);
		System.out.println(rzt);
		System.out.println("...finish");
		return rzt;
		
	}
	
	public String m2(String str)
	{
		return "ret"+str;
	}
	public static DslParser m3(String str)
	{
		return  new DslParser();
	}

}
